class Solution {
    public int search(int[] nums, int target) {
        int left = 0, right = nums.length - 1;
        while(left <= right){
            int mid = left + ((right-left)>>1);
            if (nums[mid] == target)
                return mid;
            if (nums[left] <= nums[mid]){
                // 左边是顺序区间
                int i = (target >= nums[left] && target < nums[mid]) ? (right = mid - 1) : (left = mid + 1);
            } else {
                int i = (target > nums[mid] && target <= nums[right]) ? (left = mid + 1) : (right = mid - 1);
            }
        }
        return -1;
    }
}